import { http } from "../http";
const baseUrl = "/api/user";

export interface UserType {
  id: string;
  userName: string;
  userCode: string;
  roleId: string;
  defaultUser: boolean;
}

export type GetUserListQueryType = {
  name?: string;
  userCode?: string;
  roleId?: string;
  currentPage?: number;
  numPerPage?: number;
};

export interface GetUserListResponseType {
  list: UserType[];
  currentPage: number;
  numPerPage: number;
  totalCount: number;
}

// 获取用户列表
export const getUserListAPI = (params: GetUserListQueryType) => {
  return http.post(`${baseUrl}/getUserList`, params);
};

// 添加或修改用户
export const addOrUpdateUserAPI = (params: UserType) => {
  return http.post(`${baseUrl}/addOrUpdateUser`, params);
};

// 删除用户
export const deleteUserAPI = (params: { userIds: string[] }) => {
  return http.post(`${baseUrl}/deleteUser`, params);
};
